{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fd3373e3",
   "metadata": {},
   "source": [
    "继承是面向对象变成的一个重要方式，因为通过继承，子类就可以扩展父类的功能"
   ]
  },
  {
   "cell_type": "raw",
   "id": "b6075d89",
   "metadata": {},
   "source": [
    "class Dog(Mammal, Runnable):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc83e1be",
   "metadata": {},
   "source": [
    "通过多重继承，一个子类就可以同时获得多个父类的所有功能"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "493167f5",
   "metadata": {},
   "source": [
    "### MixIn"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bb2ecb4a",
   "metadata": {},
   "source": [
    "为了更好地看出继承看出，我们可以把Runnable改为RunnableMixIn。"
   ]
  },
  {
   "cell_type": "raw",
   "id": "63a0a21e",
   "metadata": {},
   "source": [
    "class Dog(Mammal, RuunableMixIn, CarnivorousMixIn):\n",
    "    pass"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46bb8f1f",
   "metadata": {},
   "source": [
    "### 小结"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5bbcd1d6",
   "metadata": {},
   "source": [
    "Python允许多重继承，因此，MixIn是一种常见的设计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fbf1ed3f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
